﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Licenta1.RayTracer
{
    public class Vector
    {
        public double x, y, z;

        public Vector(double x, double y, double z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public Vector Normalize()
        {
            return this * (1 / this.Length());
        }

        public double Length()
        {
            return Math.Sqrt(x * x + y * y + z * z);
        }

        public static double Distance(Vector a, Vector b)
        {
            return (a - b).Length();
        }

        public static Vector operator -(Vector a, Vector b)
        {
            return new Vector(a.x - b.x, a.y - b.y, a.z - b.z);
        }

        public static Vector operator +(Vector a, Vector b)
        {
            return new Vector(a.x + b.x, a.y + b.y, a.z + b.z);
        }

        public static Vector operator *(Vector a, double b)
        {
            return new Vector(a.x * b, a.y * b, a.z * b);
        }

        public static double operator *(Vector a, Vector b)
        {
            return a.x * b.x + a.y * b.y + a.z * b.z;
        }

        public static double Angle(Vector a, Vector b)
        {
            double x = Math.Acos((a * b)/(a.Length() * b.Length()));
            if (x >= 3.0)
                Utils.Write("x = " + x);
            return x;
        }
    }
}
